package com.gitee.ywj1352.mybatis;

/**
 * @author wenjie.yang on 2019/4/15.
 *         <p>
 *         类似于 manager 委托 Configuration & Executor 干活
 */
public class Sqlsession {
    //Configuration configuration 配置类
    private Configuration configuration;

    //Executor executor 执行器
    private Executor executor;

    public Sqlsession(Configuration configuration, Executor executor) {
        this.configuration = configuration;
        this.executor = executor;
    }

    /**
     * getMapper
     *
     * @param clazz
     */
    public <T> T getMapper(Class<T> clazz) {
        return configuration.getMapper(clazz,this);
    }

    /**
     * @param statement sql 语句
     * @param parameter sql 参数
     * @param <T>
     * @return
     */
    public <T> T selelctOne(String statement, String parameter) {
        return executor.query(statement, parameter);
    }


}
